package com.neuedu.api.input;

import java.util.Random;

/**
 * @author 金山
 * 项目：javase
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/10/2413:56
 */
public class MyRandom {

    public static void main(String[] args) {

        // 工具类， 用于产生随机数（伪随机）
        Random rnd = new Random();


        // for (int i = 0; i < 10 ; i++) {
        //     System.out.println("rnd.nextInt() = " + rnd.nextInt());
        //     System.out.println("rnd.nextDouble() = " + rnd.nextDouble());
        //     System.out.println("rnd.nextBoolean() = " + rnd.nextBoolean());
        // }


        // for (int i = 0; i < 10; i++) {
        //     System.out.println("rnd.nextInt(10) = " + rnd.nextInt(100)+1);
        // }
        rnd.setSeed(9999999);  //种子100
        int nums[] = {rnd.nextInt(15),rnd.nextInt(15),rnd.nextInt(15),rnd.nextInt(15),rnd.nextInt(15),rnd.nextInt(15)};
        //排序之前
        System.out.println("\"排序之前\" = " + "排序之前");
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i]+"\t");
        }
        System.out.println();
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums.length - 1 - i; j++) {
                if (nums[j] > nums[j + 1]) {
                    int temp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j+1] = temp;
                }
            }
        }

        System.out.println("\"排序之后\" = " + "排序之后");
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i]+"\t");
        }
        System.out.println();


    }
}
